from openpyxl import load_workbook
from openpyxl.formatting.rule import CellIsRule
from openpyxl.styles import Font, Alignment, PatternFill, Border, Side


red_fill = PatternFill(start_color='FFC7CE', end_color='FFC7CE', fill_type='solid')
blue_fill = PatternFill(start_color='66B3FF', end_color='66B3FF', fill_type='solid')
green_fill = PatternFill(start_color='C6EFCE', end_color='C6EFCE', fill_type='solid')
yellow_fill = PatternFill(start_color='FFFF00', end_color='FFFF00', fill_type='solid')


# 日涨跌
pct_rule = CellIsRule(operator='lessThan', formula=[0], stopIfTrue=True, fill=green_fill)

# 周涨跌
week_pct_rule = CellIsRule(operator='lessThan', formula=[0], stopIfTrue=True, fill=green_fill)

# 月涨跌
month_pct_rule = CellIsRule(operator='lessThan', formula=[0], stopIfTrue=True, fill=green_fill)


week_inc_num_rule = CellIsRule(operator='lessThanOrEqual', formula=[-4], stopIfTrue=True, fill=yellow_fill)

# LP
lplt10_rule = CellIsRule(operator='lessThanOrEqual', formula=[10], stopIfTrue=True, fill=blue_fill)
lplt20_rule = CellIsRule(operator='between', formula=[10, 20], stopIfTrue=True, fill=green_fill)
lpgt99_rule = CellIsRule(operator='greaterThanOrEqual', formula=[99], stopIfTrue=True, fill=red_fill)

rellp_rule = CellIsRule(operator='lessThanOrEqual', formula=[1], stopIfTrue=True, fill=blue_fill)

drawdown_rule = CellIsRule(operator='lessThan', formula=[0], stopIfTrue=True, fill=blue_fill)